package com.hichina.client;

import com.hichina.client.util.ResponseUtils;
import com.hichina.exception.HiChinaException;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by IntelliJ IDEA.
 * User: zigang.wang
 * Date: 12-3-1
 * Time: 下午1:32
 * To change this template use File | Settings | File Templates.
 */
public class DomainInfo {
    private String domain;      //域名
    private String companyName;  //公司名称
    private String loginUrl;    //邮局登录地址
    private String homePageUrl;    //公司主页
    private int usedAccountCount;  //公司邮箱员工数
    protected String logoUrl;
    protected String title;

    public DomainInfo(){}

    public DomainInfo(String jsonContent) throws HiChinaException {
        try {
            JSONObject json = ResponseUtils.checkResponse(jsonContent);
            setDomain(json.getString("domain"));
            setCompanyName(json.getString("companyName"));
            setLoginUrl(json.getString("loginURL"));
            setHomePageUrl(json.getString("homePageURL"));
            setUsedAccountCount(json.getInt("usedAccountCount"));
            setLogoUrl(json.getString("logoUrl"));
            setTitle(json.getString("title"));
        } catch (JSONException e) {
            throw new HiChinaException("parse json error");
        }
    }

    public String getLogoUrl() {
        return logoUrl;
    }

    public void setLogoUrl(String logoUrl) {
        this.logoUrl = logoUrl;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }

    public String getHomePageUrl() {
        return homePageUrl;
    }

    public void setHomePageUrl(String homePageUrl) {
        this.homePageUrl = homePageUrl;
    }

    public int getUsedAccountCount() {
        return usedAccountCount;
    }

    public void setUsedAccountCount(int usedAccountCount) {
        this.usedAccountCount = usedAccountCount;
    }

    @Override
    public String toString() {
        return "DomainInfo{" +
                "domain='" + domain + '\'' +
                ", companyName='" + companyName + '\'' +
                ", loginUrl='" + loginUrl + '\'' +
                ", homePageUrl='" + homePageUrl + '\'' +
                ", usedAccountCount=" + usedAccountCount +
                '}';
    }
}
